import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../layout/index.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: () => import('../views/home/index.vue'),
        name: 'Home',
        meta: {
          title: '首页',
          icon: 'home',
          affix: true
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/index.vue'),
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: 'managementarticles',
        component: () => import('@/views/article/index.vue'),
        name: 'ManagementArticles',
        meta: {
          title: '文章管理',
          icon: 'document',
          affix: true,
          breadCrumd: [
            {
              title: '文章列表',
              path: '/managementarticles'
            }
          ]
        }
      },
      {
        path: 'managementstatistic',
        component: () => import('@/views/static/index.vue'),
        name: 'Managementstatistic',
        meta: {
          title: '统计管理',
          icon: 'static',
          affix: true,
          breadCrumd: [
            {
              title: '统计列表',
              path: '/managementstatistic'
            }
          ]
        }
      },
      {
        path: 'managementtag',
        component: () => import('@/views/tag/index.vue'),
        name: 'managementtag',
        meta: {
          title: '标签',
          icon: 'tag',
          affix: true,
          breadCrumd: [
            {
              title: '标签列表',
              path: '/managementtag'
            }
          ]
        }
      },
      {
        path: 'managementtype',
        component: () => import('@/views/type/index.vue'),
        name: 'managementtype',
        meta: {
          title: '类型',
          icon: 'managementtype',
          affix: true,
          breadCrumd: [
            {
              title: '类型列表',
              path: '/managementtype'
            }
          ]
        }
      },
      {
        path: 'managementmenu',
        component: () => import('@/views/menu/index.vue'),
        name: 'Managementmenu',
        meta: {
          title: '菜单管理',
          icon: 'menu',
          affix: true,
          breadCrumd: [
            {
              title: '菜单列表',
              path: '/managementmenu'
            }
          ]
        }
      },
      {
        path: 'managementuser',
        component: () => import('@/views/user/index.vue'),
        name: 'managementuser',
        meta: {
          title: '用户管理',
          icon: 'managementuser',
          affix: true,
          breadCrumd: [
            {
              title: '用户列表',
              path: '/managementuser'
            }
          ]
        }
      },
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(), // hash 模式
  // history: createWebHistory(), // history模式
  routes
})

export default router
